Does using str in the above statement change the information in it?

Answer:

No. Using the information does not change it. This is the same as with a primitive variable: using it in an arithmetic expression does not change its information.

Larger Example

Here is a slightly larger version of the example program, now with a new variable of a primitive type:

class EgString2
{

  public static void main ( String[] args )
  {
    String str;
    long   value;
    
    str   = new String( "The Gingham Dog" );
    value = 32912;

    System.out.println( str   );
    System.out.println( value );
  }
}

When the statement

str   = new String( "The Gingham Dog" );

is executed, a new object is created and a reference to it is placed in str.

QUESTION 8:

What happens when the statement

value = 32912;

is executed?